// NAVIGATOR.cpp : Implementation of NAVIGATOR

#include "stdafx.h"
#include "NAVIGATOR.h"


// NAVIGATOR

STDMETHODIMP NAVIGATOR::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IDMAlgorithmNavigation
	};

	for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}
////
//
// IDMDAGNavigation 
//
////

STDMETHODIMP NAVIGATOR::MoveToNextTree(void)
{
	// Set the current node to be the root node of the next tree in the forest that
	// describes your model. Models are typically represented using a single tree. If 
	// the current tree is the last one, you return S_FALSE.

	return S_FALSE;
}

	
STDMETHODIMP NAVIGATOR::GetNodeID(
	/* [out] */ DM_DAGNodeID*	out_pNodeID)
{
	// Set *out_pNodeID to be the current node id
	
	*out_pNodeID = (DM_DAGNodeID) -1;

	return S_OK;
}


STDMETHODIMP NAVIGATOR::LocateNode(
	/* [in] */ DM_DAGNodeID in_NodeID)
{
	// Set the current node to be the one indicated by in_NodeID

	return S_OK;
}

STDMETHODIMP NAVIGATOR::ValidateNodeID(
	/* [in] */ DM_DAGNodeID in_NodeID)
{
	// Return E_FAIL if in_NodeID does not correspond to a valid node id

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetParentCount(
	/* [out] */ ULONG*	out_pulParents)
{
	// Set *out_pulParents to be the number of parents of the current node

	*out_pulParents = 0;

	return S_OK;
}

STDMETHODIMP NAVIGATOR::MoveToParent(
	/* [in] */ ULONG in_ParentIndex)
{
	// Change the current node to be the given parent of the 
	// current node.

	return S_OK;
}


STDMETHODIMP NAVIGATOR::GetParentNodeID(
	/* [in] */ ULONG in_ParentIndex,
	/* [out] */ DM_DAGNodeID *out_pNodeID)
{
	// Set *out_pNodeID to be the node ID of the given parent

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetChildCount(
	/* [out] */ ULONG*	out_pulChild)
{
	// Set *out_pulChild to be the number of children of the current node

	*out_pulChild = 0;

	return S_OK;
}

STDMETHODIMP NAVIGATOR::MoveToChild(
	/* [in] */ ULONG in_ChildIndex)
{
	// Set the current node to be the given child of the current node

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetChildNodeID(
	/* [in] */ ULONG			in_ChildIndex,
	/* [out] */ DM_DAGNodeID*	out_pNodeID)
{
	// Set *out_pNodeID to be the node id of the given child of the current node

	*out_pNodeID = (DM_DAGNodeID) -1;

	return S_OK;
}

	
STDMETHODIMP NAVIGATOR::MoveToNextLeaf(
	/* [in] */ DM_DAGNodeID in_ScopeNodeID)
{
	// Set the current node to be the next leaf (in an order you decide)
	// that has node in_ScopeNodeID as an ancestor. Return S_FALSE if the
	// current node is the last such leaf.

	return S_OK;
}

STDMETHODIMP NAVIGATOR::AddRefNodeID(
	/* [in] */ DM_DAGNodeID in_NodeID)
{
	// Called to indicate that a reference is being made to
	// a node. You must keep any per-node resources available
	// for that reference.

	return S_OK;
}


STDMETHODIMP NAVIGATOR::ReleaseNodeID(
	/* [in] */ DM_DAGNodeID in_NodeID)
{
	// Called when a reference to the given node is released. Once
	// the ref count for a node is zero, you may release any node-specific
	// resources you allocated.

	return S_OK;
}

////
//
// IDMAlgorithmNavigation
//
////


STDMETHODIMP NAVIGATOR::GetNodeProperty(
	/* [in] */ IDMContextServices*	in_pContext,
	/* [in] */ DM_NODE_PROP			in_PropID,
	/* [in] */ DMVariantPtr			io_pValue)
{
	// Set *io_pValue to the appropriate value, depending on the property
	// desired by the caller. If the current node does not support the given
	// property, the function should return S_FALSE.
	//
	// Following are the allowed "simple" properties, the types expected for the DMVariantPtr, 
	// and a description. The "non simple" properties (DMNP_ATTRIBUTES and DMNP_DISTRIBUTION)
	// are returned using 

	// DMNP_TYPE (ULONG)		: the "type" of the current node. The set of types currently recognized
	//							  by the server are defined (as const ULONG) in "oledbdm.h":
	//
	//									DM_NODE_TYPE_MODEL        
	//									DM_NODE_TYPE_REGRESSION_TREE_ROOT
	//									DM_NODE_TYPE_TREE_INTERIOR    
	//									DM_NODE_TYPE_DISTRIBUTION 
	//									DM_NODE_TYPE_CLUSTER      
	//									DM_NODE_TYPE_UNKNOWN      
	//
	//						  If you implement your own browser, you may define your own types
	//
	// DMNP_CONDITION_XML (BSTR) : the "condition" corresponding to the current node, in XML
	//
	// DMNP_RULE_XML (BSTR)	: the "rule" corresponding to the current node, in XML
	//
	// DMNP_PROBABILITY	(double) : the probability corresponding to the current node
	//
	// DMNP_MARGINAL_PROBABILITY (double) : the marginal probability corresponding to the current node
	//
	// DMNP_CAPTION	(BSTR) : the caption of the current node
	//
	// DMNP_SUPPORT	(double) : the support (number of cases) corresponding to the current node
	//
	// DMNP_MODEL_COLUMN_NAME (BSTR) : the "column name" corresponding to the current node
	//
	// DMNP_DESCRIPTION	(BSTR) : longer verion of the caption
	//
	// DMNP_SCORE (double) : the score of the node
	//
	// DMNP_SHORT_CAPTION (BSTR) : shorter version of the caption
	//
	//
	// For the string outputs, you need to allocate using the
	// appropriate methods of in_pContext.

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetNodeArrayProperty(
	/* [in] */ IDMContextServices*	in_pContext,
	/* [in] */ DM_NODE_PROP			in_PropID,
	/* [out] */ ULONG*				out_pulArraySize,
	/* [out] */ void**				out_prgArrayBuffer)
{
	// Same as above, except for "non simple" properties.

	// DMNP_ATTRIBUTES (DMVariantPtr* BSTR)	: a set of attribtues corresponding to the current node
	// DMNP_DISTRIBUTION (DM_ATTRIBUTE_STAT*) : the distribution corresponding to the 
	//											current node						
	
	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetNodeUniqueName(
	/* [in] */ IDMContextServices*	in_pContext,
	/* [out] */ DMString*			io_pstrUniqueName)
{
	// Return the unique string name of the current node

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetNodeIDFromUniqueName(
	/* [in] */ IDMContextServices*	in_pContext,
    /* [in] */ DMString*			in_pstrUniqueName,
    /* [out] */ DM_DAGNodeID*		out_pNodeID)
{
	// Translate from unique string name to node id

	return S_OK;
}

STDMETHODIMP NAVIGATOR::GetUniqueNameFromNodeID( 
    /* [in] */ IDMContextServices*	in_pContext,
    /* [in] */ DM_DAGNodeID			in_NodeID,
    /* [out] */ DMString*			out_pstrUniqueName)
{
	// Translate from node id to unique string name

	return S_OK;
}

